﻿using Sai.Core.Introspection;

namespace Sai.Test.TestDataBuilders
{
	public class InstanceConstructorDeclarationBuilder
	{
		private TypeName typeName;
		private bool isObsolete = false;
		private ParameterCollection parameters = new ParameterCollection();

		public static InstanceConstructorDeclarationBuilder InstanceConstructor()
		{
			return new InstanceConstructorDeclarationBuilder();
		}

		public InstanceConstructorDeclarationBuilder ForType(TypeName t)
		{
			this.typeName = t;

			return this;
		}

		public InstanceConstructorDeclarationBuilder ForType(string name)
		{
			this.typeName = new TypeName(new FullyQualifiedName(name));

			return this;
		}

		public InstanceConstructorDeclarationBuilder IsObsolete()
		{
			this.isObsolete = true;

			return this;
		}

		public InstanceConstructorDeclarationBuilder WithParameter(Parameter param)
		{
			this.parameters.Add(param);

			return this;
		}

		public InstanceConstructorDeclarationBuilder WithParameter(string typeName)
		{
			this.parameters.Add(new Parameter(new TypeName(new FullyQualifiedName(typeName))));

			return this;
		}

		public InstanceConstructorDeclaration Build()
		{
			return new InstanceConstructorDeclaration(this.typeName, 
								new ObsoleteMarker(this.isObsolete), 
								this.parameters);
		}
	}
}

